<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSanitationCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     * 站点设备类型
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sanitation_categories', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::create('sanitation_category_files', function (Blueprint $table) {
            //字段定义
            $table->increments('id');
            $table->integer('category_id')->unsigned()->comment('站点设备类型id')->nullable();
            $table->foreign('category_id')->on('sanitation_categories')->references('id')->onDelete('set null');
            $table->BigInteger('file_id')->unsigned()->comment('图片所属的文件信息')->nullable();
            $table->foreign('file_id')->on('file_upload')->references('id')->onDelete('set null');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sanitation_categories');
        Schema::dropIfExists('sanitation_category_files');
    }
}
